package com.leyou.personnel.controller;


import com.leyou.common.pojo.Result;
import com.leyou.annotation.AuthorityForResultCheck;
import com.leyou.personnel.data.entity.AdministratorsManager;
import com.leyou.personnel.data.vo.ManagerListSearchVo;
import com.leyou.personnel.service.AdministratorsManagerService;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xhh
 * @since 2022-05-18
 */
@RestController
@RequestMapping("/leyou.personnel/administrators-manager")
public class AdministratorsManagerController {
    
    @Autowired
    private AdministratorsManagerService administratorsManagerService;

    /**
     * 管理员全查
     *
     * @author: xhh
     * @date: 2022/5/23
     * @description: 分页+搜索条件
     * @return: Result
     * @params: ManagerListSearchVo
     */
    @AuthorityForResultCheck(authority = "au006")
    @RequestMapping(value = "/managerList",method = RequestMethod.POST)
    public Result managerList(@RequestBody ManagerListSearchVo vo){
        return administratorsManagerService.managerList(vo);
    }
    /**
     * 管理员添加
     * 
     * @author: xhh
     * @date: 2022/5/23
     * @description: 
     * @return: 
     * @params: 
     */
    @AuthorityForResultCheck(authority = "au005")
    @RequestMapping(value = "/managerInsert",method = RequestMethod.POST)
    private Result managerInsert(@RequestBody AdministratorsManager manager){
        return administratorsManagerService.managerInsert(manager);
    }
    /**
     * 管理员批量删除
     *
     * @author: xhh
     * @date: 2022/5/23
     * @description: 
     * @return: 
     * @params: 
     */
    @AuthorityForResultCheck(authority = "au007")
    @RequestMapping(value = "/managerDel",method = RequestMethod.POST)
    private Result managerDel(@RequestParam("dataList") List<String> list){
        return administratorsManagerService.managerDel(list);
    }
    /**
     * 重置密码
     *
     * @author: xhh
     * @date: 2022/5/23
     * @description:
     * @return:
     * @params:
     */
    @AuthorityForResultCheck(authority = "au008")
    @RequestMapping(value = "/resetManagerPassword",method = RequestMethod.POST)
    public Result resetManagerPassword (String managerAccountNumber){
        return administratorsManagerService.resetManagerPassword(managerAccountNumber);
    }
    /**
     * 添加时获取管理员账号
     *
     * @author: xhh
     * @date: 2022/5/23
     * @description:
     * @return:
     * @params:
     */
    @AuthorityForResultCheck(authority = "au005")
    @RequestMapping(value = "/getGenerateManagerAccountNumber",method = RequestMethod.POST)
    public Result getGenerateManagerAccountNumber(){

        return administratorsManagerService.getGenerateManagerAccountNumber();
    }
}

